
	function loadStation(){
    	var province=$("div[name=province] input[name=province]").val();
    	var city=$("div[name=city] input[name=city]").val();
    	var area=$("div[name=area] input[name=area]").val();
    	$.ajax({
            type:"POST",
            url:"../station/accountStationList",
            dataType:"json",
            //contentType:"application/json",
            data:{"province":province,
                "city":city,
                "area":area,
                "pageSize":"10000"},
            success:function(dataStr){
                $(".choose-list").empty();
                $("#chosenSt").empty();
                var stations=dataStr.serviceStations;
                if(stations!=null&&stations.length>0){
                	for(var i=0;i<stations.length;i++){
                		var $li =$('<li class="list-group-item" onclick="addSite(this)">'+stations[i].serverStationName+'</li>');
                		$li.append('<input type="hidden" value='+stations[i].serverStationCode+'/>');
                        $(".choose-list").append($li)
                		
                	}
                }
            }
        });
    }
	
	//全局变量

	//站点选择框确定事件
    function addStationEvt(){
         /*$("#chosenSt li").each(function(i,liE){
             var personSt = {
                 "personalZhyCode":personCode,
                 "serverStationCode":$(liE).find("input").val()
             }
             _psersonStation.push(personSt);
         });*/
         hideEdit();
    }

	//站点点击事件
    function addSite(obj){
        var accountRole = $("input[name='role']:checked").val();
        if(accountRole){
            if(accountRole == 1){
                doAddSite(obj);
            }else{
                var chosenSitesCount = $("#chosenSt li").length;
                if(chosenSitesCount <= 0){
                    doAddSite(obj);
                }else{
                    zhyAlert("不能再添加服务站了！");
                    return ;
                }
            }
        }else{
            zhyAlert("请选择角色！");
            return ;
        }
    }

    function doAddSite(obj){
        obj.remove();//移除被选择项
        var str =$(obj).html();
        var $li=$("<li  class='list-group-item'></li>");
        var $span=$('<span class="badge cancel_icon" onclick="cancelSite(this)"></span>');
        $li.html(str);
        $span.appendTo($li);
        $(".choosed-list").prepend($li);
    }

    function cancelSite(obj){
        var str =$(obj).parent().text();//添加取消项
        var stationCode = $(obj).parent().find("input");
        var $li =$('<li class="list-group-item" onclick="addSite(this)">'+str+'</li>');//添加取消项
        $li.append(stationCode);
        $(".choose-list").append($li)//添加取消项
        $(obj).parents("li").remove();
    }
    //显示弹框
    function deleteM(obj,className,id){
        $(".zhy_zhezhao_pop").height($("html").height());
        $(".zhy_zhezhao_pop").show();
        var top = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; //兼容scrolltop写法
        var win_h = $(window).height();
        var this_h = $("." + className).height();
        var cha = win_h - this_h;
        if (cha > 0) {
            top += cha / 2;
        } else {
            top += 0;
        }
        $("." + className).css("top", top).show();
    }
    // 隐藏修改弹框
    function hideEdit() {
        $(".zhy_zhezhao_pop").hide();
        $(".zhy_popa").hide();
    }
    //检查账号的角色和站点数量是否匹配
    function checkStaions(){
        var chosenLenth = $("#chosenSt li").length;
        var _role = $("input[name='role']:checked").val();
        if(_role != 1 && chosenLenth > 1){
            zhyAlert("账号角色不是多站点管理员，不能选择多个服务站！");
            return false;
        }
        return true;
    }

    function submitEvt(personCode){
        var accountId = $("#accountId").val();
        //账户信息
        var _person = {
            "accountId":accountId,
            "personalZhyCode":personCode,
            "name":$.trim($("#personName").val()),
            "phone":$.trim($("#phone").val()),
            "sex":$("input[name='sex']:checked").val(),
            "idCard":$.trim($("#personId").val()),
            "department":$.trim($("#department").val())
        };

        //账户角色
        var _personRole ={
            "personalZhyCode":personCode,
            "roleId":$("input[name='role']:checked").val()
        };

        var _psersonStation = [];
        $("#chosenSt li").each(function(i,liE){
            var personSt = {
                "personalZhyCode":personCode,
                "serverStationCode":$(liE).find("input").val()
            }
            _psersonStation.push(personSt);
        });
        //账户模块操作权限
        var _moduleOpts = [];
        //遍历所有的module
        $("#moduleOpts .form-group").each(function(i,modul){
            if($(modul).is(":visible")){
                var moduleCode = $(modul).children("input").val();
                //遍历module下选中的 操作选项
                $(modul).find(":checked").each(function(m,inpt){
                    var _opCode = $(inpt).val();
                    var opt = {"moduleCode":moduleCode,"optionCode":_opCode};
                    _moduleOpts.push(opt);
                });
            }
        });
        //防止重复提交,设置按钮不可用
		if(! $("#accountForm").validationEngine("validate")) return ;
		
        $('#submitBtn').attr('disabled',"true");
        $.ajax({
            type:"POST",
            url:postUrl,
            dataType:"json",
            data:{"pesonInfo":JSON.stringify(_person),
                "personRole":JSON.stringify(_personRole),
                "personStations":JSON.stringify(_psersonStation),
                "moduleOpts":JSON.stringify(_moduleOpts)},
            success:function(dataStr){
                if(dataStr.data){
                    //zhyAlert("保存成功！");
                    //跳转列表页
                    window.location.href = "../account/accountList";
                }else{
                    zhyAlert(dataStr.failureMessage);
                    $('#submitBtn').removeAttr("disabled"); //移除disabled属性
                }

            }
        });
    }

    function roleEvt(roleId){
        if(roleId != '1'){
            $("#site").show();
            $("#multisite").hide();
        }else {
            $("#site").hide();
            $("#multisite").show();
        }
    }

    